package com.xxhui.serializationdemo.module;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by hui on 2016/7/9.
 */
public class Student implements Parcelable {

    private int id;
    private String name;

    protected Student(Parcel in) {
        this.id = in.readInt();
        this.name = in.readString();
    }

    public static final Creator<Student> CREATOR = new Creator<Student>() {
        @Override
        public Student createFromParcel(Parcel in) {
            return new Student(in);
        }

        @Override
        public Student[] newArray(int size) {
            return new Student[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel to, int i) {
        to.writeInt(this.id);
        to.writeString(this.name);
    }

    public Student() {
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Student:" +
                "\t 学号：" + id +
                "\t 姓名：" + name ;
    }
}
